package com.zmn.plat.services.impl.service.group;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.zmn.plat.model.entity.service.group.ServiceGroup;
import com.zmn.plat.model.entity.service.group.ServiceGroupQuery;
import com.zmn.plat.model.vo.service.group.ServiceGroupDetailVO;
import com.zmn.plat.model.vo.service.group.ServiceGroupVO;
import com.zmn.plat.model.vo.service.item.ServiceGroupExportVO;
import com.zmn.plat.persistence.interfaces.service.group.ServiceGroupDao;
import com.zmn.plat.services.interfaces.service.group.ServiceGroupService;

@Service
public class ServiceGroupServiceImpl implements ServiceGroupService {

    @Resource
    ServiceGroupDao faultGroupDao;

    @Override
    public ServiceGroup findByKey(Integer groupId) {
        return faultGroupDao.findByKey(groupId);
    }

    @Override
    @Cacheable(key = "'service:group:key:' + #p0", cacheNames = "redis1d")
    public ServiceGroup findByKeyWithCache(Integer groupId) {
        return faultGroupDao.findByKey(groupId);
    }

    @Override
    public List<ServiceGroup> listPageByQuery(ServiceGroupQuery query) {
        int count = countByQuery(query);
        query.setTotalCount(count);
        return faultGroupDao.listPageByQuery(query);
    }

    @Override
    public List<ServiceGroupExportVO> listExportExcelPageByQuery(ServiceGroupQuery query) {
        return faultGroupDao.listExportExcelPageByQuery(query);
    }

    @Override
    public List<ServiceGroup> listByQuery(ServiceGroupQuery query) {
        return faultGroupDao.listByQuery(query);
    }

    @Override
    public List<ServiceGroupDetailVO> listServCategoryByTariffId(Integer tariffId) {
        return faultGroupDao.listServCategoryByTariffId(tariffId);
    }

    @Override
    public List<ServiceGroupDetailVO> listBaseCategoryByTariffIdAndServCategId(Integer tariffId, Integer servCategId) {
        return faultGroupDao.listBaseCategoryByTariffIdAndServCategId(tariffId, servCategId);
    }

    @Override
    public List<ServiceGroupDetailVO> listGroupByTariffIdAndServCategIdAndCategOneId(Integer tariffId, Integer servCategId, Integer categOneId) {
        return faultGroupDao.listGroupByTariffIdAndServCategIdAndCategOneId(tariffId, servCategId, categOneId);
    }

    @Override
    public List<ServiceGroup> listByTariffIdAndServCategIdAndCategOneId(ServiceGroupQuery faultGroupQuery) {
        return faultGroupDao.listByTariffIdAndServCategIdAndCategOneId(faultGroupQuery);
    }

    @Override
    public List<ServiceGroup> listByGroupIds(List<Integer> groupIds) {
        return faultGroupDao.listByGroupIds(groupIds);
    }

    @Override
    public List<ServiceGroup> listAll() {
        return faultGroupDao.listAll();
    }

    @Override
    public Integer countByQuery(ServiceGroupQuery query) {
        return faultGroupDao.countByQuery(query);
    }

    @Override
    public Integer updateStatusByKey(ServiceGroup faultGroup) {
        return faultGroupDao.updateStatusByKey(faultGroup);
    }

    @Override
    public Integer updateStatusBatchByKey(List<Integer> ids, Integer status, String mcStaffName) {
        return faultGroupDao.updateBatchStatusByKey(ids, status, mcStaffName);
    }

    @Override
    public Integer updateSortByKey(ServiceGroup faultGroup) {
        return faultGroupDao.updateSortByKey(faultGroup);
    }

    @Override
    public Integer updateSortByKey(Integer groupId, Integer sort, String mcStaffName) {
        ServiceGroup faultGroup = new ServiceGroup();
        faultGroup.setGroupId(groupId);
        faultGroup.setSort(sort);
        faultGroup.setUpdater(mcStaffName);

        return updateSortByKey(faultGroup);
    }

    @Override
    public Integer updateByKey(ServiceGroup faultGroup) {
        return faultGroupDao.updateByKey(faultGroup);
    }

    @Override
    public Integer insert(ServiceGroup faultGroup) {
        return faultGroupDao.insert(faultGroup);
    }

    @Override
    public Integer insertBatch(List<ServiceGroupVO> newFaultGroupList) {
        return faultGroupDao.insertBatch(newFaultGroupList);
    }

    @Override
    public Integer deleteByKey(Integer groupId) {
        return faultGroupDao.deleteByKey(groupId);
    }

    @Override
    public Integer deleteByGroupIds(List<Integer> groupIds) {
        return faultGroupDao.deleteByGroupIds(groupIds);
    }
}